<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class persons {
        name
        age
        constructor(name, age) {
          this.name = name
          this.age = age
        }
        speak() {
          console.log(`我叫${this.name}今年${this.age}岁`)
        }
      }
      let p1=new persons('韩立',30)
      console.log(p1);
      p1.speak()


    


// 继承
class student extends persons{
    city
    constructor(name,age,city){
       super(name,age)
       this.city=city
    }
    study() {
        console.log(`我叫${this.name}今年${this.age}岁,在努力学习...，家在${this.city}`);
    }
    // override添加这个防止重写错单词
     speak() { 
    }
}

let s1=new student('李潇',12,'湖南')
s1.speak()
s1.study()
console.log(s1.age);
    </script>
  </body>
</html>
